<?php
/**                                          
 * 用户应用
 * @author M2
 * @version 1.0
 * create Date 2013-04-27
 */
class UserAppModel extends Model {
	/**
	 * 获取用户安装的应用
	 * @param int $id 用户ID
	 */
	public function getInstallApps($id,$type="allApp") {
		$list = $this->table ( C ( 'DB_PREFIX' ) . 'user_app as uapp' )->join ( C ( 'DB_PREFIX' ) . 
				'app as app on uapp.app_id=app.app_id' )->field ( 'app.*,uapp.display_order' )->
				where("uapp.uid=$id and app.status=2 and app.app_id IS NOT NULL")->order ( 'uapp.display_order' )->select ();
		if ($type === "allApp"){
			$default_list = M('app')->where("`status` = 1")->select();
			$list = empty($list)?$default_list:(empty($default_list)?$list:array_merge($list,$default_list));
		}
		return $list;
	}
}
?>